#include "stdafx.h"

XINPUT_STATE menuDef::state = { NULL };
BOOL bReadyToNotify = FALSE;

int menuDef::whiteMaterial = NULL;
int menuDef::gradientMaterial = NULL;
int menuDef::normalFont = NULL;

int menuDef::dwScreenMaxX = NULL, menuDef::dwScreenMaxY = NULL;
int menuDef::dwScreenCenterX = NULL, menuDef::dwScreenCenterY = NULL;

float menuDef::fMenuPosX = 0.0f, menuDef::fMenuPosY = 0.0f;
float menuDef::fMenuWidth = 380.0f;

BOOL menuDef::bMenuOpen = false;

BOOL CG::bInGameCached = FALSE;
BOOL CG::bConnected = FALSE;
BOOL CG::bLobbyInitialized = FALSE;
BOOL CG::bQuittingGame = FALSE;
BOOL CG::bKillThread = FALSE;
BOOL CG::bExitedThread = FALSE;
BOOL MenuOptions::bRME_NoClip = FALSE;
BOOL MenuOptions::bRME_NoClipBind = FALSE;
BOOL MenuOptions::bRME_GodMode = FALSE;
DWORD MenuOptions::dwRME_GodMode = 0, MenuOptions::dwRME_SuperSpeed = 0, MenuOptions::dwRME_Invisibility = 0, MenuOptions::dwRME_InfraredVision = 0, MenuOptions::dwRME_SetMode = 0;
DWORD MenuOptions::dwRME_Client_GodMode = 0, MenuOptions::dwRME_Client_SuperSpeed = 0, MenuOptions::dwRME_Client_Invisibility = 0, MenuOptions::dwRME_Client_InfraredVision = 0, MenuOptions::dwRME_Client_SetMode = 0;

DWORD MenuOptions::dwRME_AllClients_GodMode_ON = 0, MenuOptions::dwRME_AllClients_GodMode_OFF = 0, MenuOptions::dwRME_AllClients_SuperSpeed_ON = 0, MenuOptions::dwRME_AllClients_SuperSpeed_OFF = 0, MenuOptions::dwRME_AllClients_Blackscreen = 0, MenuOptions::dwRME_AllClients_TakeWeaponsAway = 0, MenuOptions::dwRME_AllClients_TakeAmmoAway = 0;

DWORD MenuOptions::dwRME_ChangeMapIndex = 0;
DWORD MenuOptions::dwRME_ChangeGameTypeIndex = 0;

BOOL MenuOptions::bLaunchCustomGT = FALSE, MenuOptions::bRainbowGT = FALSE, MenuOptions::bCycleGT = FALSE;

BOOL MenuOptions::bRenameSelectedClient = FALSE;
BOOL MenuOptions::bCustomRenameAllClients = FALSE;
BOOL MenuOptions:: g_bSpinBotEnabled = FALSE;

DWORD MenuOptions::dwGiveWeaponIndex = 0;
DWORD MenuOptions::dwRME_GiveWeaponIndex = 0;
BOOL MenuOptions::bMakeEveryoneThrowNades = FALSE;
BOOL MenuOptions::bAntiQuitAuto = FALSE;
DWORD MenuOptions::dwAntiQuitIndex = 0;
BOOL MenuOptions::bMoveEveryoneAround = FALSE;
DWORD MenuOptions::dwRME_ModelIndex = 0;
BOOL MenuOptions::bWalkOnCountdown = FALSE;

BOOL MenuOptions::bAimbot = FALSE;
DWORD MenuOptions::dwAimbotType = NULL, MenuOptions::dwTargetType = NULL, MenuOptions::dwTargetBone = NULL;
BOOL MenuOptions::bNoSpread = FALSE;
BOOL MenuOptions::bAutoShoot = FALSE;
BOOL MenuOptions::bPingPrediction = FALSE;
BOOL MenuOptions::bAntiAim = FALSE;

BOOL MenuOptions::bDrawAllies = FALSE, MenuOptions::bDrawAxis = FALSE;
DWORD MenuOptions::dwBoxType = 3;
BOOL MenuOptions::bDrawNames = FALSE, MenuOptions::bDrawDistances = FALSE, MenuOptions::bDrawWeapons = FALSE, MenuOptions::bDrawBones = FALSE;
BOOL MenuOptions::bDrawSnaplines = FALSE;
BOOL MenuOptions::bSmallCrosshair = FALSE;
BOOL MenuOptions::bHealthBar = FALSE;
BOOL MenuOptions::NeverDLC = FALSE;
BOOL MenuOptions::bRainbowEffect = TRUE; // on by default



//void AngleVectors(vec3 angles, vec3* forward, vec3* right, vec3* up) {
//	float angle;
//	float sr, sp, sy, cr, cp, cy;
//	angle = angles.y * (PI * 2.0f / 360.0f);
//	sy = sinf(angle);
//	cy = cosf(angle);
//	angle = angles.x * (PI * 2.0f / 360.0f);
//	sp = sinf(angle);
//	cp = cosf(angle);
//	angle = angles.z * (PI * 2.0f / 360.0f);
//	sr = sinf(angle);
//	cr = cosf(angle);
//
//	if (forward) {
//		forward->x = cp * cy;
//		forward->y = cp * sy;
//		forward->z = -sp;
//	}
//
//	if (right) {
//		right->x = (-1 * sr * sp * cy + -1 * cr * -sy);
//		right->y = (-1 * sr * sp * sy + -1 * cr * cy);
//		right->z = -1 * sr * cp;
//	}
//
//	if (up) {
//		up->x = (cr * sp * cy + -sr * -sy);
//		up->y = (cr * sp * sy + -sr * cy);
//		up->z = cr * cp;
//	}
//}

void VectorToAngle(vec3* direction, vec3* out) {
	float forward, yaw, pitch, PiDiv = (180.0f / XM_PI);

	if (direction->y == 0 && direction->x == 0) {
		yaw = 0;
		if (direction->z > 0)
			pitch = 90;
		else
			pitch = 270;
	}
	else {
		if (direction->x)
			yaw = (atan2(direction->y, direction->x) * PiDiv);
		else if (direction->y > 0)
			yaw = 90.0f;
		else
			yaw = 270.0f;

		if (yaw < 0.0f)
			yaw += 360.0f;

		forward = sqrt((direction->x * direction->x) + (direction->y * direction->y));
		pitch = (atan2(direction->z, forward) * PiDiv);

		if (pitch < 0.0f)
			pitch += 360;
	}

	out->x = 360.0f - pitch;
	out->y = yaw;
	out->z = 0.0f;

	if (out->x > 360.0f)
		out->x -= 360.0f;
	if (out->x < 0.0f)
		out->x += 360.0f;

	if (out->y > 360.0f)
		out->y -= 360.0f;
	if (out->y < 0.0f)
		out->y += 360.0f;

	if (out->z > 360.0f)
		out->z -= 360.0f;
	if (out->z < 0.0f)
		out->z += 360.0f;
}

vec3 VectorToAngles(vec3& Delta) {
	float Forward, Yaw, Pitch;

	if (Delta.x == 0 && Delta.y == 0)
	{
		Yaw = 0;
		if (Delta.z > 0)
			Pitch = 90.0f;
		else
			Pitch = 270.0f;
	}
	else
	{
		if (Delta.x)
			Yaw = (atan2(Delta.y, Delta.x) * 57.2957804f);
		else if (Delta.y > 0)
			Yaw = 90.0f;
		else
			Yaw = 270.0f;

		if (Yaw < 0)
			Yaw += 360.0f;

		Forward = sqrt((Delta.x * Delta.x) + (Delta.y * Delta.y));
		Pitch = (atan2(Delta.z, Forward) * 57.2957804f);

		if (Pitch < 0)
			Pitch += 360;
	}
	return vec3(-Pitch, Yaw, 0);
}
